package com.hulizuofang.wol.chat.client.presenter;

import com.google.gwt.event.shared.EventBus;
import com.gwtplatform.dispatch.shared.DispatchAsync;
import com.gwtplatform.mvp.client.Presenter;
import com.gwtplatform.mvp.client.View;
import com.gwtplatform.mvp.client.proxy.PlaceRequest;
import com.gwtplatform.mvp.client.proxy.Proxy;
import com.gwtplatform.mvp.client.proxy.RevealContentEvent;
import com.hulizuofang.wol.chat.client.place.NameTokens;

public abstract class AbstractNestedPresenter<AView extends View, AProxy extends Proxy<?>> extends Presenter<AView, AProxy> {

	private final DispatchAsync dispatcher;
	private String login = null;

	public AbstractNestedPresenter(EventBus eventBus, AView view, AProxy proxy, DispatchAsync dispatcher) {
		super(eventBus, view, proxy);
		this.dispatcher = dispatcher;
	}

	@Override
	protected void revealInParent() {
		RevealContentEvent.fire(this, MainPagePresenter.TYPE_SetMainContent, this);
	}

	public DispatchAsync getDispatcher() {
		return dispatcher;
	}

	public String getLogin() {
		return login;
	}
	
	@Override
	public void prepareFromRequest(PlaceRequest request) {
		super.prepareFromRequest(request);
		login  = request.getParameter(NameTokens.LOGIN, null);
	}
}